package leetcode.秋招.广;

import java.util.Scanner;
import java.util.Stack;

/**
 * @author ：zsy
 * @date ：Created 2021/9/17 21:19
 * @description：
 */
public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String next = in.next();
        char[] chars = next.toCharArray();
        Stack<Character> stack = new Stack();
        for (int i = 0; i < chars.length; i++) {
            if (chars[i] == 'I') {
                stack.push('I');
            } else {
                if (stack.isEmpty()) {
                    System.out.println(false);
                    return;
                }
                stack.pop();
            }
        }
        System.out.println(stack.isEmpty());
    }
}
